@echo off
setlocal

REM Configure Java 8
set "JAVA_HOME=D:\software\jdk8\install"
set "PATH=%JAVA_HOME%\bin;%PATH%"

echo ========================================
echo OPC UA Client - Quick Start (Java 8)
echo ========================================
echo.

REM Verify Java version
java -version 2>&1 | findstr "1.8"
if errorlevel 1 (
    echo ERROR: Java 8 not found!
    pause
    exit /b 1
)

echo.
echo Step 1: Resolving dependencies...
mvn -f pom-java8.xml dependency:resolve -q
if errorlevel 1 goto error

echo Step 2: Compiling source code...
mvn -f pom-java8.xml compile -q
if errorlevel 1 goto error

echo Step 3: Creating JAR package...
mvn -f pom-java8.xml package -DskipTests -q
if errorlevel 1 goto error

echo.
echo ========================================
echo Build Success!
echo ========================================
echo Output: target\opc-ua-demo-client-java8.jar
echo.
echo To run the client, use: run-java8.bat
echo.
pause
exit /b 0

:error
echo.
echo ========================================
echo Build Failed!
echo ========================================
echo Running verbose build for details...
echo.
mvn -f pom-java8.xml clean compile package -DskipTests
pause
exit /b 1
